#
# Makefile - postmemd daemon
#


SHELL = /bin/sh
VPATH = include/:server/

INCDIR = -Iinclude/ -Isrclib/ -I/usr/local/include/json/
LIBS = -ljson -lev
DEPS = main.o core.o config.o io.o util.o atom.o slaves.o response.o
OBJDIR = o/

CC = gcc
CFLAGS = -pg -Wall -posix $(INCDIR)

BINDIR = bin/
BIN = postmemd

all: $(BIN)

$(BIN): createdir $(DEPS)
	@echo " -- Create execute file"
	$(CC) $(OBJDIR)*.o -o $(BINDIR)$@ $(INCDIR) $(LIBS)

main.o: main.c core.c slaves.c io.c util.c config.c response.c
	$(CC) $(CFLAGS) -c $< -o $(OBJDIR)$@

core.o: core.c util.c atom.c io.c config.c slaves.c response.c
	$(CC) $(CFLAGS) -c $< -o $(OBJDIR)$@

atom.o: atom.c config.c util.c
	$(CC) $(CFLAGS) -c $< -o $(OBJDIR)$@

config.o: config.c
	$(CC) $(CFLAGS) -c $< -o $(OBJDIR)$@

io.o: io.c core.c config.c util.c atom.c
	$(CC) $(CFLAGS) -c $< -o $(OBJDIR)$@

util.o: util.c
	$(CC) $(CFLAGS) -c $< -o $(OBJDIR)$@

slaves.o: slaves.c main.c config.c util.c core.c response.c
	$(CC) $(CFLAGS) -c $< -o $(OBJDIR)$@

response.o: response.c
	$(CC) $(CFLAGS) -c $< -o $(OBJDIR)$@

createdir:
	@mkdir -p $(OBJDIR)
	@mkdir -p $(BINDIR)

clean:
	rm -rf $(OBJDIR)
	rm -rf $(BINDIR)






